package com.demo.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.sql.Date;
import java.util.Calendar;

@Data
@TableName("tb_tournament_arrangement")
public class TournamentArrangement {
    @TableId(value = "ta_id", type = IdType.AUTO)
    private long id;
    @TableField(value = "ta_name")
    private String name;
    @TableField(value = "ta_apply_begin")
    private Date applyBegin;
    @TableField(value = "ta_apply_end")
    private Date applyEnd;
    @TableField(value = "ta_del_flag")
    private int delFlag;
    @TableField(exist = false)
    private String startMonth;


//    设置开始报名的月份（根据applyBegin提取月份）
    public void setTaStartMonth(){
//        当填写了具体报名时间且报名月份字段未写时
        if(this.applyBegin!=null&&startMonth==null){
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(this.applyBegin);	//放入Date类型数据
            int year=calendar.get(Calendar.YEAR);
            int month=calendar.MONTH;
            String mon=month>9?month+"":"0"+month;
            startMonth=year+"-"+mon;
        }
//        当报名时间未写时
        else if (this.applyBegin==null) {
            startMonth=null;
        }
    }



}
